<?php
/**
 * Created by PhpStorm.
 * User: C。
 * Date: 2019/8/13
 * Time: 9:04
 */
namespace app\home\controller;

use app\common\model\ActionPrepare as ActionPrepareModel;

/**
 * 活动报名控制器
 * Class Activeapply
 * @package app\home\controller
 */
class Actionprepare extends Base
{
    /**
     * [add  添加]
     * @param
     * @return json
     * @author [C。]
     */
    public function add()
    {
        $param = input('param.');
        $model = new ActionPrepareModel;
        $user = $this->user;
        try{
            $prepare = $model->getAllData(['aid'=>$param['aid'],'mid'=>$user['id']]);
            if(!empty($prepare)){
                return admin_json(-1, '该活动已经报名');
            }
            $param['field'] = serialize($param['field']);
            $param['mid'] = $user['id'];
            $model->addData($param);
        }catch(\Exception $e){
            systembug($e->getMessage(),2,'home/Actionprepare/add');
            return admin_json(-1, '报名失败'.$e->getMessage());
        }
        return admin_json(1, '报名成功');
    }
}